import sys
file = open("input.txt")
data = file.readlines()
N, K = map(int, data[0].split())
box = [-1] + list(map(int, data[1].split()))
num = [[0] * (K + 1 )for i in range(N + 1)]
tab = [[None] * (N + 1) for i in range(N + 1)]
maxim = [[-1, -1] for i in range(N + 1)]
for i in range(1, N + 1):
    for j in range(1, K + 1):
        if box[i] != j:
            num[i][j] = num[i - 1][j]
        else:
            num[i][j] = num[i - 1][j] + 1
            if num[i][j] > maxim[i - 1][1]:
                maxim[i] = [j, num[i][j]]
            else:
                maxim[i] = maxim[i - 1]
            
ans = N
coord = maxim[1][0]
k = 0
c = []
print(maxim)
for i in range(1, N + 1):
    for j in range(i + 1, N + 1):
        if maxim[j][1] - maxim[i - 1][1] > (abs(i - j) + 1) // 2 and maxim[j][0] == maxim[i][0]:
            k += 1
            c += [(i, j)]
print(ans + k)
print(c)